package gof.com.yew.composite;

import java.util.ArrayList;
import java.util.List;

public class Folder implements AbstractFile {
	
	private String name;
	
	List<AbstractFile> lists = new ArrayList<>(); 
	
	public void add(AbstractFile file) {
		lists.add(file);
	}
	
	public void remove(AbstractFile file) {
		lists.remove(file);
	}
	
	public AbstractFile getFile(int index) {
		return lists.get(index);
	}
	
	public Folder(String name) {
		this.name = name;
	}

	@Override
	public void killVirus() {
	
		System.out.println("<<<文件夹："+name+",进行查杀>>>");
		for (AbstractFile abstractFile : lists) {
			abstractFile.killVirus();
		}
	}

}
